/*
 * Copyright 2011 Angel Sanadinov
 *
 * This file is part of VBox WMI.
 *
 * VBox WMI is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * VBox WMI is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with VBox WMI.  If not, see <http://www.gnu.org/licenses/>.
 */

package Beans.Requests.NetworkManagement;

import Beans.Requests.RequestBean;
import Utilities.Functions;

/**
 * This is the superclass for all networks management requests.
 *
 * @author Angel Sanadinov
 */
public class NetworkManagementRequest extends RequestBean
{
    private String networkId;   //network id for the request

    /**
     * No-argument constructor. <br><br>
     * All fields are set to their invalid values.
     */
    public NetworkManagementRequest()
    {
        this.networkId = null;
    }

    /**
     * Sets the network id for the request.
     *
     * @param networkId the network id
     */
    public void setNetworkId(String networkId)
    {
        this.networkId = networkId;
    }

    /**
     * Retrieves the network id associated with this object.
     *
     * @return the network id
     */
    public String getNetworkId()
    {
        return networkId;
    }

    /**
     * Checks whether the network id associated with this request is valid.
     *
     * @return <code>true</code> if the network id is valid or <code>false</code> otherwise
     */
    protected boolean isNetworkIdValid()
    {
        return Functions.isUUIDValid(networkId);
    }

    /**
     * Checks the validity of the request object. <br><br>
     *
     * The object is considered valid only if all supplied data is valid.
     *
     * @return <code>true</code> if the object is valid or <code>false</code> otherwise
     */
    @Override
    public boolean isValid()
    {
        if(isRequestedActionValid() && isRequestorIdValid() && isServerIdValid())
            return true;
        else
            return false;
    }
}
